package service

import (
	"context"
	"fmt"
	"videosS_rpc/basic/config"

	__ "videosS_rpc/basic/proto"
	"videosS_rpc/handler/model"
)

func (s *Server) ReviewAdd(_ context.Context, in *__.ReviewAddReq) (*__.ReviewAddResp, error) {

	review := &model.Review{

		UserId:    int(in.UserId),
		VideoId:   int(in.VideoId),
		Operation: int(in.Operation),
		Reason:    int(in.Reason),
	}
	err := review.ReviewAdd(config.DB)
	if err != nil {
		return nil, fmt.Errorf("视频审核失败")
	}

	return &__.ReviewAddResp{
		ReviewId: int64(review.ID),
	}, nil
}
